<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>行政区划管理</title>
    <link rel="stylesheet" type="text/css" href="../../themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../css/default.css">
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../../js/datagrid-detailview.js"></script>
    <script type="text/javascript" src="../../js/datagrid-cellediting.js"></script>
    <script type="text/javascript" src="../../js/jquery-form.js"></script>
    <script type="text/javascript" src="../../js/app.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <script type="text/javascript" src="../../js/comm_check.js"></script>
    <script type="text/javascript" src="../../js/relax_function.js"></script>
    

</head>
<body>
    <!-- 查询条件 -->
    <div id="searchbar">
            <fieldset>
                <legend>查询条件</legend>
                    <table id="tblSearch" cellpadding="0" cellspacing="0" border="0" class="tbl-border">
                        <tr>
                         <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">区划编码：</label></td>
	                      <td class="tbl-td-border"><input class="easyui-validatebox tbl-input-left" id="regionCodeSerch" 
	                                 name="regionCode"></input></td>
	                      <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">区划名称：</label></td>
	                      <td class="tbl-td-border"><input class="easyui-validatebox tbl-input-left" id="regionNameSerch" maxlength="20"
	                                 name="regionName"></input></td>
	                      <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">是否城市：</label></td>
	                      <td class="tbl-td-border"> 
                         	‍‍<select class="easyui-combobox tbl-input-left"  id="isCitySerch" name = "isCity">
                                <option value="" selected="selected">全部</option>
								<option value="1">是</option>
								<option value="0">否</option>
                         	</select>
                         </td>
	                      <td class="tbl-td-bg-color tbl-td-border"><label class="tbl-label-right">电话区号：</label></td>
	                      <td class="tbl-td-border"><input class="easyui-validatebox tbl-input-left" id="phoneCodeSerch" 
	                                 name="phoneCode"></input></td>
                        </tr>
                    </table>
	                    <div style="padding: 5px; text-align: center;">
	                        <a href="#" class="easyui-linkbutton" icon="icon-search" onclick="loadRegionByPage()">查询</a>
	                         <a href="javascript:void(0)" class="easyui-linkbutton" icon="icon-reload" id="resetSearch">重置</a>
	                    </div>
            </fieldset>
    </div>

    <!-- 用户信息 -->
    <table  id="dg_cr" class="easyui-datagrid">
    </table>
    
<!-- 工具栏 -->
<!-- <div id="toolbar">
	    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="addUserInfo()" >添加</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="exec4Delete()">删除</a>
    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="exec4Delete()">同步标签</a>
    	
		进度条
		<div id="div_pb" style="position: absolute; width: 400px; height: 50px; right: 20%; left: 25%; top: 35%; bottom: 20%; margin-left: 50px; margin-top: 25px; display: none; text-align: center;">
	    	<img src="../../images/loading.gif" />
			<div id="pb" class="easyui-progressbar" style="width:400px;"></div>
		</div>
</div> -->

    
    <script type="text/javascript">
   
    	var size = 10;
    	var page = 1;
        
        var conf = {
              options: {
                singleSelect: false,
                ctrlSelect: true,
                showFooter: true,
                fit: true,
                fitColumns: true,
                checkOnSelect: false,
                selectOnCheck: false,
                //footer: '#toolbar',
                toolbar: '#searchbar',
                striped: true,
                
                columns: [[
                    {field: 'id', title: '行政区划id', align: 'center', halign: 'center',hidden:true},
                    {field: 'regionCode', title: '区划编码', align: 'center', halign: 'center'},
                    {field: 'regionName', title: '区划名称', align: 'center', halign: 'center'},
                    //{field: 'regionLevel', title: '区划级别', width: 150, align: 'center', halign: 'center'},
                     {field: 'is_prov', title: '是否省级',  align: 'center', halign: 'center',
                  		formatter: function(value, row, index) {
                            if(value == '1') {
                                return "是";
                            } else {
                                return "否";
                            }
                        }   },
                    {field: 'isCity', title: '是否城市(含直辖市)',  align: 'center', halign: 'center',
                  		formatter: function(value, row, index) {
                            if(value == '1') {
                                return "是";
                            } else {
                                return "否";
                            }
                        }   },
                    {field: 'phoneCode', title: '电话区号',  align: 'center', halign: 'center'}
                ]],
                pagination: true,
                pageSize: size,
                pageList: [size * 1, size * 2, size * 3, size * 5],
                pageNumber: 1,
                rownumbers: true,
                onAfterEdit: function (rowIndex, rowData, changes) {
                },
                rowStyler: function (index, row) {
                }
            }
        }; 
        
        $(function () {
            $('#pb').progressbar({
                onChange: function (value) {
                    $('.progressbar-value').css('background-color', 'red');
                }
            });
            $('#dg_cr').datagrid({footer: '#toolbar'}).datagrid('subgrid', conf);
            loadRegionByPage(page, size);
            $('#dg_cr').datagrid('getPager').pagination({
                loadMsg: '正在加载数据...',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',
                onSelectPage: function (page, size) {
                	loadRegionByPage(page, size);

                }
            });
        });
        function loadRegionByPage(page,size) {
        	page = page || 1;
            size = size || 10;
            $('#dg_cr').datagrid("loading");
            var regionCode = $('#regionCodeSerch').val();
      		var regionName = $('#regionNameSerch').val();
      		var isCity = $('#isCitySerch').combobox("getValue");
      		var phoneCode = $('#phoneCodeSerch').val();
      		
            var service = $.svc.getSVC("/region/getAllRegionPage");
            service.setPage(page, size)
            .setParam("regionCode", regionCode)
            .setParam("regionName", regionName)
            .setParam("isCity", isCity)
            .setParam("phoneCode", phoneCode);
            service.call(
                    function (response, status) {
                    	console.log(response);
                        if (response.getResult().length == '0') {
                            $('#dg_cr').datagrid("loadData", []);
                        } else {
                            $('#dg_cr').datagrid("loadData", response.getResult());
                        }
                        $('#dg_cr').datagrid("loaded");
                    });
        }
        
        //重置
        $('#resetSearch').click(function(){
        	$('#regionCodeSerch').val(""); 
        	$('#regionNameSerch').val(""); 
        	$('#phoneCodeSerch').val(""); 
        	$('#isCitySerch').combobox('setValue','');
        	loadRegionByPage();
        })
        
       
     
    </script>
</body>
</html>